/**
 * @author: lichuang.
 * @date: 2020/5/29
 * @description: 血糖血压状态判断
 */

let Status = Status || {}
let rangeNum = uni.getStorageSync('params'), statusTxt = ''

//血压状态判断
Status.pressure = (dbp, sbp) => {
  if (dbp <= rangeNum.pressureDbpNormal * 1 && sbp <= rangeNum.pressureSbpNormal * 1) {
    statusTxt = 'pNormal'
  } else if ((dbp >= rangeNum.pressureDbpNormal * 1 && dbp <= rangeNum.pressureDbpSlight * 1) || (sbp >= rangeNum.pressureSbpNormal * 1 && sbp <= rangeNum.pressureSbpSlight * 1)) {
    statusTxt = 'pSlight'
  } else if ((dbp >= rangeNum.pressureDbpSlight * 1 && dbp <= rangeNum.pressureDbpMinor * 1) || (sbp >= rangeNum.pressureSbpSlight * 1 && sbp <= rangeNum.pressureSbpMinor * 1)) {
    statusTxt = 'pMinor'
  } else if ((dbp >= rangeNum.pressureDbpMinor * 1 && dbp <= rangeNum.pressureDbpMedium * 1) || (sbp >= rangeNum.pressureSbpMinor * 1 && sbp <= rangeNum.pressureSbpMedium * 1)) {
    statusTxt = 'pMedium'
  } else if (dbp >= rangeNum.pressureDbpMajor * 1 || sbp >= rangeNum.pressureSbpMajor * 1) {
    statusTxt = 'pMajor'
  }
  return statusTxt
}

//血糖状态判断
Status.glucose = (glucose) => {
  if (glucose <= rangeNum.glucoseLow * 1) {
    statusTxt = 'gLow'
  } else if (glucose <= rangeNum.glucoseNormal * 1) {
    statusTxt = 'gNormal'
  } else if (glucose <= rangeNum.glucoseSlight * 1) {
    statusTxt = 'gSlight'
  } else if (glucose <= rangeNum.glucoseMinor * 1) {
    statusTxt = 'gMinor'
  } else if (glucose > rangeNum.glucoseMajor * 1) {
    statusTxt = 'gMajor'
  }
  return statusTxt
}

export default Status